package edu.bit.water.controller;

import edu.bit.water.entity.MetaBaseline;
import edu.bit.water.service.MetaBaselineService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

@Controller
@RequestMapping("/meta_baseline")
public class MetaBaselineController {

    @Autowired
    private MetaBaselineService metaBaselineService;

    @ResponseBody
    @RequestMapping(value = "/select", method=RequestMethod.GET)
    public Map<String, Object> queryBaseline(String stNumber) {
        Map<String, Object> result = new HashMap<>();
        List<MetaBaseline> list = metaBaselineService.queryBaseline(stNumber);
        result.put("rows", list);
        return result;
    }

    @ResponseBody
    @RequestMapping("/insert")
    public Map<String, Object> insertMetaBaseline(MetaBaseline metaBaseline) {
        metaBaseline.showContent();
        Map<String, Object> result = metaBaselineService.insertMetaBaselineService(metaBaseline);
        return result;
    }

    /**
     * 删除metaBaseline
     * author Page
     */
    @ResponseBody
    @RequestMapping("/delete")
    public Map<String, Object> deleteMetaBaseline(@RequestBody List<String>metaBaseline) {
        return metaBaselineService.deleteMetaBaseline(metaBaseline);
    }

    @ResponseBody
    @RequestMapping("/update")
    public Map<String, Object> updateMetaBaseline(MetaBaseline metaBaseline) {
        Map<String, Object> result = metaBaselineService.updateMetaBaselineService(metaBaseline);
        return result;
    }
}
